/*
 * Copyright (c) Huawei Technologies Co., Ltd. 2022-2022. All rights reserved.
 */

import path from 'path';

import { CUR_HVIGOR_VERSION, HVIGOR_USER_HOME } from '../../../cli/wrapper/wrapper-const.js';

export const DAEMON_LOG_PATH = path.resolve(HVIGOR_USER_HOME, 'daemon', 'log', CUR_HVIGOR_VERSION);

export const DAEMON_PROCESS_EXIT_TIME_OUT = 10800000; // 3小时
export const DAEMON_PROCESS_REMOVED_FROM_REGISTRY_CHECK_TIME = 30000; // 30s检测一次
export const DAEMON_SERVER_MIN_LISTEN_PORT = 45000;
export const DAEMON_SERVER_MAX_LISTEN_PORT = 45099;
export const DEFAULT_DAEMON_REGISTRY_PATH = path.resolve(HVIGOR_USER_HOME, 'daemon', 'cache', 'daemon-sec.json');
export const DEFAULT_DAEMON_META_PATH = path.resolve(HVIGOR_USER_HOME, 'meta');
export const DAEMON_WORK_KEY_LENGTH = 16;
export const DAEMON_SALT_KEY_LENGTH = 16;
export const DAEMON_ROOT_KEY_COMPONENT_LENGTH = 128;
export const KEY_FILE_PERMISSIONS = 0o600;
export const KEY_FILE_DIRECTORY_PERMISSIONS = 0o700;
export const DAEMON_SERVER_LOCAL_HOST = '127.0.0.1';
export const DAEMON_PROCESS_ACTIVE_MAX_LIMIT = 6;
export const DAEMON_INFO_IN_REGISTRY_MAX_LIMIT = 8;
export const DAEMON_SOCKETS_MAX_LIMIT = 10;
export const DAEMON_LOG_FILE_NAME_PATTEN = /^(daemon-[0-9]+\.log)(\.[0-9]+\.gz)?$/;

export const DAEMON_LOG_FILE_RETENTION_TIME = 86400000; // 1天 todo 调试阶段先暂时将1天以上的历史日志清理掉,正式发布前需要更新

export const DAEMON_LISTEN_FAILED_REASON_PREFIX = 'LISTEN_ERROR:';
